package com.lznb.cloud.repository;

import com.lznb.cloud.entity.News;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * 新闻表
 * @author mzy
 * @email 1992lcg@163.com
 * @date ${datetime}
 */
public interface NewsRepository extends JpaRepository<News, String>, JpaSpecificationExecutor<News> {

    /**
     * 根据栏目查询新闻列表
     * @param categoryId
     * @return
     */
    @Query(value = "select n from News n where n.category.categoryId=:categoryId")
    List<News>findByCategory(@Param("categoryId") String categoryId);

}
